#!/usr/bin/env bash
# Node 配置 请自行修改到你自己的内网IP
k8sServer=30.11.99.19
nodeServer=30.11.99.18
imgserver=30.11.99.19


# Node 配置结束


cat >/etc/yum.repos.d/k8s.repo <<EOF
[virt7-docker-common-release]
name=virt7-docker-common-release
baseurl=http://cbs.centos.org/repos/virt7-docker-common-release/x86_64/os/
gpgcheck=0
EOF
yum -y install --enablerepo=virt7-docker-common-release kubernetes etcd flannel

mv /etc/kubernetes/kubelet /etc/kubernetes/kubelet.bak
cat >/etc/kubernetes/kubelet<<EOF

###
# kubernetes kubelet (minion) config

# The address for the info server to serve on (set to 0.0.0.0 or "" for all interfaces)
KUBELET_ADDRESS="--address=0.0.0.0"

# The port for the info server to serve on
# KUBELET_PORT="--port=10250"

# You may leave this blank to use the actual hostname
KUBELET_HOSTNAME="--hostname-override=$nodeServer"

# location of the api-server
KUBELET_API_SERVER="--api-servers=http://$k8sServer:8078"

# pod infrastructure container
KUBELET_POD_INFRA_CONTAINER="--pod-infra-container-image=$imgserver:5000/centos/jdk:latest"

# Add your own!
KUBELET_ARGS=""

EOF

for SERVICES in kube-proxy kubelet flanneld; do
    systemctl restart $SERVICES
    systemctl enable $SERVICES
    systemctl status $SERVICES
done